package com.example.new1;

import java.util.ArrayList;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;

public class BookmarkActivity extends Activity { 
	
	ListView list;
	MyAdapter adapter;
	ArrayList<DataActivity> data;
	Cursor result, result1;
	DatabaseAdapter db;
	DataActivity da;
	String ph, home;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.bookmark);
	    registerForContextMenu(this.findViewById(R.id.listView1));
	    // TODO Auto-generated method stub
	    
	    // connect database
		db = new DatabaseAdapter(this);
		db.open();
		result = db.getBookmark();
		
		setData();
		
	    adapter = new MyAdapter(this, data);
	    
	    list = (ListView)findViewById(R.id.listView1);
	    list.setAdapter(adapter);    
	}
	
	void setData(){
		data = new ArrayList<DataActivity>();
	
		if(result.moveToFirst()){
			do{
				da = new DataActivity(
						R.drawable.ic_stadium_unselected,
						result.getString(0),
						R.drawable.ic_delete_unselected
				);	
				data.add(da);
			}while(result.moveToNext());
		}	
		else
			data.add(null);
		
		db.close();
	}  
}
